#include <QtPlugin>

#include <QFileDialog>
#include <QWidget>
#include <QPushButton>
#include <QHBoxLayout>
#include <QProgressBar>
#include <QTimer>
#include <QMessageBox>
#include <QSpinBox>

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>

#include <QInputDialog>

#include "QCVModuleInterface.h"
#include "QCVModuleHandlerInterface.h"

#ifndef ModulePlayer_H
#define ModulePlayer_H

/**
@class ModulePlayer
@brief Module de lecture de fichiers vidéos ou images
*/

class ModulePlayer:public QObject,QCVModuleInterface
{
  Q_OBJECT
	Q_INTERFACES(QCVModuleInterface)
	
	public:
	 void init(QCVModuleHandlerInterface * parent);
   void free();
   
   cv::Mat & process();
   void setInput(int n,const cv::Mat & m);
   
   QWidget* widget();
   QString getName();
   int nbInputs();
   QString help(int id);
   
	 QString getParams();
	 bool setParams(QString params);

	 QCVModuleInterface * clone();

  public slots:
    void load();
    void start_stop();
    void get_frame();
    void loadFromWebCam();
		void setTimerPeriod(int p);
	
  private:
    QWidget * win;
    QPushButton * pb_load;
    QPushButton * pb_play_pause;
    QProgressBar * progress_bar;
    QHBoxLayout * layout;
    QTimer * timer;
		QPushButton * pb_webcam;
 		QVBoxLayout * vlayout;
		QSpinBox * sb_periode;		

    QCVModuleHandlerInterface * parent;
	  cv::VideoCapture cap;
	  cv::Mat frame;
};                    

#endif
